home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_03
/
1103100a
< prev
next >
Wrap
Text File
|
1993-01-03
|
1KB
|
52 lines
// date7.h
class ostream;
class Date
{
int month;
int day;
int year;
public:
// Constructors
Date()
{month = day = year = 0;}
Date(int m, int d, int y)
{month = m; day = d; year = y;}
// Accessor Functions
int get_month() const
{return month;}
int get_day() const
{return day;}
int get_year() const
{return year;}
Date operator-(const Date& d2) const;
Date& operator-()
{month = -month; day = -day; year = -year;
return *this;}
int compare(const Date&) const;
// Relational operators
int operator<(const Date& d2) const
{return compare(d2) < 0;}
int operator<=(const Date& d2) const
{return compare(d2) <= 0;}
int operator>(const Date& d2) const
{return compare(d2) > 0;}
int operator>=(const Date& d2) const
{return compare(d2) >= 0;}
int operator==(const Date& d2) const
{return compare(d2) == 0;}
int operator!=(const Date& d2) const
{return compare(d2) != 0;}
// I/O operators
friend ostream& operator<<(ostream&, const Date&);
friend istream& operator>>(istream&, Date&);
};